local stock1 = tonumber(redis.call('get', KEYS[1]))
local num1 = tonumber(ARGV[1])
if (stock1 < num1) then
  return 500
end
local stock2 = tonumber(redis.call('get', KEYS[2]))
local num2 = tonumber(ARGV[2])
if (stock1 < num2) then
  return 500
end
local stock3 = tonumber(redis.call('get', KEYS[3]))
if (stock2 < num2) then
  return 500
end
local num3 = tonumber(ARGV[3])
if (stock3 < num3) then
  return 500
end
redis.call('incrby', KEYS[1], 0 - num1)
redis.call('incrby', KEYS[2], 0 - num2)
redis.call('incrby', KEYS[3], 0 - num3)
return 200